
/*
 * Copyright 2002-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2021原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory.support;

import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;

/**
 * Simple interface for bean definition readers that specifies load methods with
 * {@link Resource} and {@link String} location parameters.
 *
 * <p>Concrete bean definition readers can of course add additional
 * load and register methods for bean definitions, specific to
 * their bean definition format.
 *
 * <p>Note that a bean definition reader does not have to implement
 * this interface. It only serves as a suggestion for bean definition
 * readers that want to follow standard naming conventions.
 *
 * @author Juergen Hoeller
 * @since 1.1
 * @see org.springframework.core.io.Resource
 */
/**
 *用于bean定义读取器的简单接口，它使用
 *｛@link Resource｝和｛@linkString｝位置参数。
 *
 *＜p＞具体的bean定义读者当然可以添加额外的
 *bean定义的加载和注册方法，特定于
 *它们的bean定义格式。
 *
 *＜p＞注意，bean定义读取器不必实现
 *此界面。它仅作为bean定义的建议
 *希望遵循标准命名约定的读者。
 *
 *@作者Juergen Hoeller
 *@自1.1
 *@参见org.springframework.core.io.Resource
 */
public interface BeanDefinitionReader {

	/**
	 * Return the bean factory to register the bean definitions with.
	 * <p>The factory is exposed through the {@link BeanDefinitionRegistry} interface,
	 * encapsulating the methods that are relevant for bean definition handling.
	 */
	/**
	 *返回要注册bean定义的bean工厂。
	 *＜p＞工厂通过｛@link BeanDefinitionRegistry｝接口公开，
	 *封装与bean定义处理相关的方法。
	 */
	BeanDefinitionRegistry getRegistry();

	/**
	 * Return the {@link ResourceLoader} to use for resource locations.
	 * <p>Can be checked for the {@code ResourcePatternResolver} interface and cast
	 * accordingly, for loading multiple resources for a given resource pattern.
	 * <p>A {@code null} return value suggests that absolute resource loading
	 * is not available for this bean definition reader.
	 * <p>This is mainly meant to be used for importing further resources
	 * from within a bean definition resource, for example via the "import"
	 * tag in XML bean definitions. It is recommended, however, to apply
	 * such imports relative to the defining resource; only explicit full
	 * resource locations will trigger absolute path based resource loading.
	 * <p>There is also a {@code loadBeanDefinitions(String)} method available,
	 * for loading bean definitions from a resource location (or location pattern).
	 * This is a convenience to avoid explicit {@code ResourceLoader} handling.
	 * @see #loadBeanDefinitions(String)
	 * @see org.springframework.core.io.support.ResourcePatternResolver
	 */
	/**
	 *返回用于资源位置的｛@link ResourceLoader｝。
	 *＜p＞可以检查｛@code ResourcePatternResolver｝接口和强制转换
	 *从而用于为给定资源模式加载多个资源。
	 *＜p＞｛@code null｝返回值表明绝对资源加载
	 *不可用于此bean定义读取器。
	 *<p>这主要用于导入更多资源
	 *从bean定义资源中，例如通过“import”
	 *标记。但是，建议应用
	 *相对于定义资源的此类进口；仅显式完整
	 *资源位置将触发基于绝对路径的资源加载。
	 *＜p＞还有一个｛@code loadBeanDefinitions（String）｝方法可用，
	 *用于从资源位置（或位置模式）加载bean定义。
	 *这是避免显式｛@code ResourceLoader｝处理的方便。
	 *@see#loadBeanDefinitions（字符串）
	 *@参见org.springframework.core.io.support.ResourcePatternResolver
	 */
	@Nullable
	ResourceLoader getResourceLoader();

	/**
	 * Return the class loader to use for bean classes.
	 * <p>{@code null} suggests to not load bean classes eagerly
	 * but rather to just register bean definitions with class names,
	 * with the corresponding classes to be resolved later (or never).
	 */
	/**
	 *返回用于bean类的类加载器。
	 *＜p＞｛@code null｝建议不要急于加载bean类
	 *而是仅仅用类名注册bean定义，
	 *相应的类将稍后（或永远）解析。
	 */
	@Nullable
	ClassLoader getBeanClassLoader();

	/**
	 * Return the {@link BeanNameGenerator} to use for anonymous beans
	 * (without explicit bean name specified).
	 */
	/**
	 *返回用于匿名bean的｛@link BeanNameGenerator｝
	 *（未指定显式bean名称）。
	 */
	BeanNameGenerator getBeanNameGenerator();


	/**
	 * Load bean definitions from the specified resource.
	 * @param resource the resource descriptor
	 * @return the number of bean definitions found
	 * @throws BeanDefinitionStoreException in case of loading or parsing errors
	 */
	/**
	 *从指定的资源加载bean定义。
	 *@param resource资源描述符
	 *@return找到的bean定义的数量
	 *在加载或分析错误时@throws BeanDefinitionStoreException
	 */
	int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException;

	/**
	 * Load bean definitions from the specified resources.
	 * @param resources the resource descriptors
	 * @return the number of bean definitions found
	 * @throws BeanDefinitionStoreException in case of loading or parsing errors
	 */
	/**
	 *从指定的资源加载bean定义。
	 *@param resources资源描述符
	 *@return找到的bean定义的数量
	 *在加载或分析错误时@throws BeanDefinitionStoreException
	 */
	int loadBeanDefinitions(Resource... resources) throws BeanDefinitionStoreException;

	/**
	 * Load bean definitions from the specified resource location.
	 * <p>The location can also be a location pattern, provided that the
	 * {@link ResourceLoader} of this bean definition reader is a
	 * {@code ResourcePatternResolver}.
	 * @param location the resource location, to be loaded with the {@code ResourceLoader}
	 * (or {@code ResourcePatternResolver}) of this bean definition reader
	 * @return the number of bean definitions found
	 * @throws BeanDefinitionStoreException in case of loading or parsing errors
	 * @see #getResourceLoader()
	 * @see #loadBeanDefinitions(org.springframework.core.io.Resource)
	 * @see #loadBeanDefinitions(org.springframework.core.io.Resource[])
	 */
	/**
	 *从指定的资源位置加载bean定义。
	 *＜p＞位置也可以是位置模式，前提是
	 *此bean定义读取器的｛@link ResourceLoader｝是
	 *｛@code ResourcePatternResolver｝。
	 *@param location要用｛@code ResourceLoader｝加载的资源位置
	 *（或｛@code ResourcePatternResolver｝）
	 *@return找到的bean定义的数量
	 *在加载或分析错误时@throws BeanDefinitionStoreException
	 *@参见#getResourceLoader（）
	 *@see#loadBeanDefinitions（org.springframework.core.io.Resource）
	 *@see#loadBeanDefinitions（org.springframework.core.io.Resource[]）
	 */
	int loadBeanDefinitions(String location) throws BeanDefinitionStoreException;

	/**
	 * Load bean definitions from the specified resource locations.
	 * @param locations the resource locations, to be loaded with the {@code ResourceLoader}
	 * (or {@code ResourcePatternResolver}) of this bean definition reader
	 * @return the number of bean definitions found
	 * @throws BeanDefinitionStoreException in case of loading or parsing errors
	 */
	/**
	 *从指定的资源位置加载bean定义。
	 *@param定位要用｛@code ResourceLoader｝加载的资源位置
	 *（或｛@code ResourcePatternResolver｝）
	 *@return找到的bean定义的数量
	 *在加载或分析错误时@throws BeanDefinitionStoreException
	 */
	int loadBeanDefinitions(String... locations) throws BeanDefinitionStoreException;

}
